/*
 * Copyright 1999-2018 Alibaba Group Holding Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.ouwen.smartpay.service.chain.slotchain;


import org.apache.http.util.Asserts;

/***
 *@author <a href="http://youngitman.tech">青年IT男</a>
 *@version v1.0.0
 *@className ResourceWrapper
 *@description 管理资源包装用来对资源做管理
 *@JunitTest: {@link  }
 *@date 11:11 2020-04-22
 *
**/
public class ResourceWrapper {

    protected final String service;

    protected final String partnerId;

    public ResourceWrapper(String service, String partnerId) {
        Asserts.notBlank(service, "resource service cannot be empty");
        Asserts.notBlank(partnerId, "partnerId cannot be null");
        this.service = service;
        this.partnerId = partnerId;
    }

    public String getService() {
        return service;
    }

    public String getPartnerId() {
        return partnerId;
    }


    @Override
    public int hashCode() {
        return getService().hashCode() + getPartnerId().hashCode();
    }


    @Override
    public boolean equals(Object obj) {
        if (obj instanceof ResourceWrapper) {
            ResourceWrapper rw = (ResourceWrapper) obj;
            return rw.getService().equals(getService()) && rw.getPartnerId().equals(getPartnerId());
        }
        return false;
    }
}
